package com.example.testrxjava.adapter;

import android.support.annotation.Nullable;
import android.text.Html;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.testrxjava.R;
import com.example.testrxjava.fragment.article.ArticleListBean;

import java.util.List;

/**
 * 项目名称：TestRxjava
 *
 * @Author 郭迎辉
 * Create by 11:58 on 2019/4/19.
 * Describe:
 */
public class ActicleListAdapter extends BaseQuickAdapter<ArticleListBean.DataBean.DatasBean, BaseViewHolder> {
    public ActicleListAdapter(int layoutResId, @Nullable List<ArticleListBean.DataBean.DatasBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ArticleListBean.DataBean.DatasBean item) {
        if(item == null) return;


        helper.setText(R.id.homeItemAuthorTv,item.getAuthor())
                .setText(R.id.homeItemDateTv,item.getNiceDate())
                .setText(R.id.homeItemTitleTv, Html.fromHtml(item.getTitle()))
                .setText(R.id.homeItemTypeTv,item.getSuperChapterName()+" / "+item.getChapterName())
                .addOnClickListener(R.id.homeItemLoveIv);
        if(item.isCollect()){
            helper.getView(R.id.homeItemLoveIv).setSelected(true);
        }else{
            helper.getView(R.id.homeItemLoveIv).setSelected(false);
        }
    }

}
